﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cosmetic.Logic;
using Cosmetic.DataEntity;
using System.Data;

namespace WebApp.newes
{
    public partial class News : System.Web.UI.Page
    {
        private articleclassManger m_CategoryManager = new articleclassManger();
        private articleManger m_ArticleManager = new articleManger();
        private PlateManager PM = new PlateManager();
        int m = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ListView6.DataSource = PM.Gethotpro();//最近销售
                this.ListView6.DataBind();
                if (!string.IsNullOrEmpty(Request.QueryString["CID"]))
                {
                    BindArticle();
                }
            }
        }


        private void BindArticle()
        { 
            int m_CID = Convert.ToInt32(Request.QueryString["CID"]);
                article theArticle = this.m_ArticleManager.GetProductById(Convert.ToInt32(this.Request.QueryString["CID"]));
                theArticle.count = theArticle.count + 1;
                m_ArticleManager.Update();


                //DataTable dt = articleManger.GetProductInfoByIds(m_CID);

                //if (dt.Rows.Count > 1)
                //{
                    this.ltlTitle.Text = theArticle.tilte;// dt.Rows[0]["tilte"].ToString();
                    this.ltlCreateTime.Text = theArticle.createTime.Value.ToLongDateString();// dt.Rows[0]["createTime"].ToString();
                    this.ltlContent.Text = theArticle.contents;//["contents"].ToString();
                    m = theArticle.classid.Value;
                    //Literal6.Text = dr["count"].ToString();
                    //Literal5.Text = dr["tilte"].ToString();

                    DataTable dt2 = articleclassManger.GetProductInfoByIds(m);

                    this.ltlClass.Text = dt2.Rows[0]["name"].ToString();

                    this.Page.Title = theArticle.tilte + "-日花商城";
                    this.Page.MetaKeywords = theArticle.tilte + "，医疗器械，医用耗材，日花商城";
                //}
        }

        public string spliteStr(string title)
        {
            if (title.Length > 10)
            {
                title = title.Substring(0, 10) + "…";
            }
            return title;
        }
        public string spliteStrs(string title)
        {
            if (title.Length > 15)
            {
                title = title.Substring(0, 15) + "…";
            }
            return title;
        }
    }
}